package com.meichis.mcsappframework.dialog;

import android.content.Context;

import androidx.annotation.NonNull;

import com.meichis.mcsappframework.R;

import java.util.ArrayList;

public class DropDownBuilder<T> {

    BuilderParams params;

    public DropDownBuilder(@NonNull Context context) {
        this.params = new BuilderParams(context);
    }


    public DropDownBuilder setTitle(String title) {
        params.setTitle(title);
        return this;
    }

    public DropDownBuilder setFilter(boolean filter) {
        params.setFilter(filter);
        return this;
    }

    public DropDownBuilder setRlColorBg(int rlColorBg) {
        params.setRlColorBg(rlColorBg);
        return this;
    }

    public DropDownBuilder setTextData(String textData) {
        params.setTextData(textData);
        return this;
    }

    public DropDownBuilder setCancelable(boolean cancelable) {
        params.setCancelable(cancelable);
        return this;
    }

    public DropDownBuilder setSingleLine(boolean singleLine) {
        params.setSingleLine(singleLine);
        return this;
    }

    public DropDownBuilder setTextStatus(int textStatus) {
        params.setTextStatus(textStatus);
        return this;
    }

    public DropDownBuilder setData(ArrayList<T> mList) {
        params.setmList(mList);
        return this;
    }

    public DropDownBuilder setSelectedListener(DropDownDialog.SelectedListener selectedListener) {
        params.setSelectedListener(selectedListener);
        return this;
    }


    public DropDownDialog build() {
        DropDownDialog<T> dialog = new DropDownDialog<>(params.mContext);
        dialog.Build(params);
        return dialog;
    }


    class BuilderParams {
        private Context mContext;
        //标题
        private String title = "请选择";
        //是否添加筛选框
        private boolean isFilter = false;
        //dialog弹出框的背景颜色
        private int rlColorBg = R.color.blue;
        //显示的字段
        private String TextData;
        //对话框能否被取消
        private boolean Cancelable = true;
        //文本内容是否只显示一行
        private boolean isSingleLine = true;
        //
        private int textStatus;

        //数据
        private ArrayList<T> mList = null;
        //选中监听
        private DropDownDialog.SelectedListener selectedListener;


        public BuilderParams(Context context) {
            this.mContext = context;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public boolean isFilter() {
            return isFilter;
        }

        public void setFilter(boolean filter) {
            isFilter = filter;
        }

        public int getRlColorBg() {
            return rlColorBg;
        }

        public void setRlColorBg(int rlColorBg) {
            this.rlColorBg = rlColorBg;
        }

        public String getTextData() {
            return TextData;
        }

        public void setTextData(String textData) {
            TextData = textData;
        }

        public boolean isCancelable() {
            return Cancelable;
        }

        public void setCancelable(boolean cancelable) {
            Cancelable = cancelable;
        }

        public boolean isSingleLine() {
            return isSingleLine;
        }

        public void setSingleLine(boolean singleLine) {
            isSingleLine = singleLine;
        }

        public int getTextStatus() {
            return textStatus;
        }

        public void setTextStatus(int textStatus) {
            this.textStatus = textStatus;
        }

        public ArrayList<T> getmList() {
            return mList;
        }

        public void setmList(ArrayList<T> mList) {
            this.mList = mList;
        }

        public DropDownDialog.SelectedListener getSelectedListener() {
            return selectedListener;
        }

        public void setSelectedListener(DropDownDialog.SelectedListener selectedListener) {
            this.selectedListener = selectedListener;
        }
    }


}
